package com.example.chenhaosblog.service.impl;

import com.example.chenhaosblog.mapper.DaoSupport;
import com.example.chenhaosblog.service.ArticleService;
import com.example.chenhaosblog.utils.PageData;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class ArticleServiceImpl implements ArticleService {


    @Resource(name = "daoSupport")
    private DaoSupport dao;


    @Override
    public List<PageData> findAll(PageData pageData) throws Exception {
       return (List<PageData>) dao.findForList("AticleMapper.findAll", pageData);

    }



    @Override
    public void add(PageData pageData) throws Exception {
        dao.save("AticleMapper.insert",pageData);

    }

    @Override
    public void update(PageData pageData) throws Exception {

        dao.update("AticleMapper.update",pageData);
    }

    @Override
    public PageData findView(PageData pageData) throws Exception {
        return (PageData)dao.findForObject("AticleMapper.findInfo", pageData);
    }

    @Override
    public void del(PageData pageData) throws Exception {
        dao.delete("AticleMapper.update",pageData);
    }

    @Override
    public void dels(List<String> ids) throws Exception {
        dao.delete("AticleMapper.dels",ids);


    }

    @Override
    public List<PageData> getLanguage(PageData pageData) throws Exception {
        return (List<PageData>) dao.findForList("LanguageTitleMapper.findAll", pageData);
    }




}
